<template>
	
	<!-- 定时发表 -->
    <el-dialog center width="50%" :visible.sync="dialogVisible">
      	<div slot="title" class="upload-dialog-title">
        	定时发表
      	</div>
      	<div>
          	<!-- 自定义发布时间 -->
          	<publish-time
          		@update-time="updateTime"
          	></publish-time>

      	</div>
      	<div slot="footer" class="upload-dialog-footer">
          	<el-button type="danger" @click="cancel">取消</el-button>
          	<el-button type="primary" @click="confirm">确认</el-button>
      	</div>
    </el-dialog>

</template>

<script>
	import PublishTime from "./publishTime"
	export default{
		components:{
			PublishTime
		},
		props:{
			visible:{
				type:Boolean,
				default:false
			}
		},
		data(){
			return {
				dialogVisible:false,
				publishTime:''
			}
		},
		watch:{
			visible(val){

				this.dialogVisible = val;
			}
		},
		methods:{
			//更新选择的发布日期
			updateTime(date){
				this.publishTime = date;
			},
			//取消
			cancel(){
				//日期清空
				this.publishTime = '';
				//通知父组件更新日期,关闭模态框
				this.$emit('cancel',this.publishTime);
				this.dialogVisible = false;
			},
			//确定
			confirm(){
				//通知父组件更新日期,关闭模态框
				this.$emit('comfirm',this.publishTime);
				this.dialogVisible = false;
			}
		}
	}
</script>